package com.ruoyi.nuclein.Feign.Fallback;

import com.ruoyi.basicdata.domain.Resident;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.nuclein.Feign.BasicDataFeign;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class ResidentRallbackFactory implements FallbackFactory<BasicDataFeign> {


    @Override
    public BasicDataFeign create(Throwable cause) {
        cause.printStackTrace();
       return new BasicDataFeign() {
           @Override
           public AjaxResult getCountByBuildId(Long id) {
               System.err.println("查询住户总人数的时候进熔断啦，报错啦");
               return AjaxResult.error("查询住户总人数的时候进熔断啦，报错啦");
           }

           @Override
           public AjaxResult changeState(Long id) {
               System.err.println("修改楼栋状态的时候进熔断啦，报错啦");
               return AjaxResult.error("修改楼栋状态的时候进熔断啦，报错啦");
           }

           @Override
           public List<Resident> getResidentByBuildingId(Long id) {
               System.err.println("根据楼栋id查询住户的时候进熔断啦，报错啦");
               return null;
           }

           @Override
           public AjaxResult updateBatchStateByBuildingId(Long id) {
               System.err.println("修改楼栋全部住户状态的时候进熔断啦，报错啦");
               return AjaxResult.error("修改楼栋全部住户状态的时候进熔断啦");
           }

           @Override
           public AjaxResult updateStateById(Long id) {
               return AjaxResult.error("修改单个住户状态的时候进熔断啦");
           }

           @Override
           public AjaxResult taskChangeState(List<Long> ids) {
               System.err.println("修改楼栋全部住户状态的时候进熔断啦，报错啦");
               return AjaxResult.error("修改楼栋全部住户状态的时候进熔断啦");
           }
       };
    }
}
